package com.talent.study.hello;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author: hszhou
 * @Date: 2025/6/5 16:27
 * @Description: 必须描述类做什么事情, 实现什么功能
 */
public class TimeConverter implements Converter<Long> {



    @Override
    public Class supportJavaTypeKey() {return Long.class;}

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {return CellDataTypeEnum.STRING;}

    @Override
    public WriteCellData<?> convertToExcelData(Long value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String format = sdf.format(new Date(value));
        return new WriteCellData<>(format);
    }
    //将excel的数据类型转为java数据类型

}